package com.khalil.kkadmin.module.ai.model;

import com.khalil.kkadmin.common.web.RespResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ai/model")
public class AiModelController {
    private final AiModelManager aiModelManager;

    public AiModelController(AiModelManager aiModelManager) {
        this.aiModelManager = aiModelManager;
    }

    @GetMapping("list")
    public RespResult<List<AiModel>> list() {
        List<AiModel> list = aiModelManager.list(ListQuery.builder().build());
        return RespResult.ok(list);
    }

    @GetMapping("/{id}")
    public RespResult<AiModel> get(@PathVariable Long id) {
        AiModel aiModel = aiModelManager.get(id);
        return RespResult.ok(aiModel);
    }

    @PostMapping("")
    public RespResult<AiModel> create(@RequestBody AiModel aiModel) {
        AiModel aiModel1 = aiModelManager.create(aiModel);
        return RespResult.ok(aiModel1);
    }

    @PutMapping("")
    public RespResult<AiModel> update(@RequestBody AiModel aiModel) {
        AiModel aiModel1 = aiModelManager.update(aiModel);
        return RespResult.ok(aiModel1);
    }

    @DeleteMapping("/{id}")
    public RespResult<Void> delete(@PathVariable Long id) {
        aiModelManager.delete(id);
        return RespResult.ok(null);
    }
}
